package com.example.blog_system.dao;
import com.example.blog_system.model.domain.Article;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleMapper {

    //根据id查询
    @Select("SELECT * FROM t_article WHERE id = #{id}")
    Article selectArticleWithId(@Param("id")Integer id);

    //文章分页查询
    @Select("SELECT * FROM t_article order by id desc")
    List<Article> selectArticleWithPage();

    //删除文章
    @Delete("delete FROM t_article WHERE id = #{id}")
    void deleteArticleWithId(@Param("id")int id);

    //统计文章数量
    @Select("SELECT count(1) FROM t_article")
    Integer countArticle();

    //新增文章
    public Integer publishArticle(Article article);

    //通过id新增文章
    Integer updateArticleWithId(Article article);
}
